﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.controllers {
    import flash.events.*;
    import flash.utils.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.*;
    import net.wooga.pets.constants.*;
    import org.robotlegs.mvcs.*;
    import net.wooga.pets.models.world.*;

    public class InitWorldCompleteCommand extends Command {

		[Inject]
        public var world:WorldModel;
		[Inject]
        public var userModel:UserModel;
		[Inject]
        public var gameStateModel:GameStateModel;
		[Inject]
        public var tickModel:TickModel;
		[Inject]
        public var roomSlotsModel:RoomSlotsModel;
		[Inject]
        public var tutorialModel:TutorialModel;
		[Inject]
        public var sessionModel:SessionModel;

        override public function execute():void{
            var _local2:InfoEvent;
            this.gameStateModel.initWorldComplete = true;
            contextView.dispatchEvent(new Event(EventConstants.ON_PRELOADING_COMPLETE, true));
            if (this.gameStateModel.isFirstComplete){
                this.gameStateModel.isFirstComplete = false;
                dispatch(new TrackingEvent(TrackingConst.TRACK, TrackingConst.LOADING, {progress:100, elapsed:getTimer()}));
                _local2 = new InfoEvent(EventConstants.CALL_EXTERNAL, ProtocolConstants.HIDE_OVERLAY);
                dispatch(_local2);
                dispatch(new InfoEvent(EventConstants.INIT_TREE));
            };
            dispatch(new Event(EventConstants.CHECK_LETTERS));
            this.gameStateModel.isFacadeVisible = false;
            dispatch(new Event(EventConstants.SHOW_HOSPITAL_DISPLAY));
            dispatch(new Event(EventConstants.ENABLE_FRIENDS_MENU));
            dispatch(new GameEvent(GameEvent.TUTORIAL_STATE_INITIALIZE));
            if (this.userModel.level >= 5){
                dispatch(new Event(EventConstants.SHOW_INVENTORY_GEMS));
            };
            this.tickModel.pause = false;
            dispatch(new Event(EventConstants.SHOW_MAIN_VIEW));
            var _local1:Boolean = this.world.hasAreaType(GameConstants.TYPE_RECEPTION);
            if (_local1){
                dispatch(new InfoEvent(EventConstants.CHECK_KIOSK_TUTORIAL, null, TutorialModel.KIOSK_CLICK_ON_SHOP));
                dispatch(new InfoEvent(EventConstants.CHECK_FOUNTAIN_TUTORIAL, null, {state:TutorialModel.FOUNTAIN_CLICK_ON_SHOP}));
                dispatch(new InfoEvent(EventConstants.CHECK_KINDERGARTEN_TUTORIAL, null, TutorialModel.KINDERGARTEN_CLICK_ON_SHOP));
            };
            dispatch(new Event(EventConstants.HIDE_VISIT_FRIEND_TRANSITION));
            dispatch(new Event(EventConstants.PRELOAD_LEVELUP_ICON));
            dispatch(new Event(EventConstants.PRELOAD_COMPUTER_DISPLAY));
            dispatch(new Event(EventConstants.INIT_KINDERGARTEN_TEASER));
            dispatch(new Event(EventConstants.INIT_SOUND));
            dispatch(new ShopEvent(ShopEvent.UPDATE_SHOP_ITEMS));
        }

    }
}//package net.wooga.pets.controllers 
